<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<script src="/static/js/filecss.js" type="text/javascript" ></script>
<link href="/static/lib/rangeslider/rangeslider.css" rel="stylesheet" >
<link href="/static/lib/fonts/googleapi.css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet">
<script src="/static/lib/polyfill/polyfill.min.js"></script>

</head>
<body class="hold-transition skin-red sidebar-mini">
<div class="box box-primary" id="signup_template_formpreview" style="height: auto;" >
 			<form  id="signup_submit_form">
 			
 			
              <div class="box-body" id="signup_template_formpreview_render_wrap"> </div>
              
              </form>
              <div class="box-footer" id="box-footer">
                <!--  <button type="button" class="btn btn-default pull-right" v-on:click="cancel">关闭</button> -->
                
                <button type="button"  class="btn btn-info pull-right" v-bind:style="{ display: submitbuttonshow}" style="display: none;" v-on:click="doSubmit">提交</button>
              </div>
</div>
<script src="/static/lib/jquery/dist/jquery-2.1.4.min.js"></script>
<script src="/static/lib/vue/vue.min.v2.js" type="text/javascript" ></script>
<script src="/static/js/filejs.js"></script>
<script src="/static/lib/kevinformbuilder/assets/form-config-default.js"></script>
<script src="/static/lib/kevinformbuilder/assets/form-builder.min.js"></script>
<script src="/static/lib/kevinformbuilder/assets/form-render.min.js"></script> 
<script src="/static/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/lib/ueditor/ueditor.all.min.js" type="text/javascript" charset="utf-8"> </script>

<script type="text/javascript">

new Vue({
    el: '#signup_template_formpreview',
    data:  {
    	metId: null,
    	submitbuttonshow:"none",
	    bus:new Vue()
 }, 
	mounted : function() {
		
		var o = document.getElementById("signup_template_formpreview");
		var h = document.body.clientWidth ; //高度
		window.parent.postMessage(h,"*");
		
	var _this=this;
	 var metId=zfesRoutie.getUrlPatam("metId");
	 _this.metId=metId;
	 var url="/met/service/pub/signupDefine/loadSignupModel";
     zfesAjax.ajaxTodo(url,{"metId":metId}, function(data){
   		if(data.data.signupModel.formJson&&data.data.signupModel.formScript){
   			_this.submitbuttonshow="";
   			var signupModel=data.data.signupModel;
   			var formJson=jQuery.parseJSON(signupModel.formJson);
       		var formScript=signupModel.formScript;
      	  	var fbRender = document.getElementById('signup_template_formpreview_render_wrap');
	 	     var formRenderOpts = {
	 	    	formData : formScript,//参数名必须是formData
	 	    	dataType: 'xml',
	 	    	  controlConfig: {
	 		        	 'file.fineuploader': {
	 				        		js: '/static/lib/fine-uploader/jquery.fine-uploader.min.js',
	 				        		css: '/static/lib/fine-uploader/fine-uploader.min.css',
	 				        		handler: '/met/service/tenant/signupDefine/uploadAttaches',
	 				        		retry: {
	 				                    enableAuto: false
	 				                },
	 				                background:"#FFF",
	 				                multiple: false,
	 				        		 callbacks:{
	 					                onComplete:  function(id,  fileName,  responseJSON)  {
	 					                	if(responseJSON.success!=true){
	 					                		alertSwal.errorText("上传失败");
	 					                		return;
	 					                	}
	 					                	var fileUrl=responseJSON.url;
	 					                	var element=$(this._options.element);
	 					                	var uploadContainer= $(element).parent()
	 					                	var inputId=$(element).attr("id").replace("-wrapper","");
	 					                	var inputEl=$(uploadContainer).find("#"+inputId+"");
	 					                	$(inputEl).val(fileUrl);
	 					                }
	 				        		} ,
	 				        		validation: {
	 				                   // allowedExtensions: ['jpeg', 'jpg', 'gif', 'png']
	 				                }
	 				        	
	 				        		// other fine uploader configuration options here
	 		        		 }
	 		        	},
	 	  		};
	 	     $(fbRender).formRender(formRenderOpts);
   		}else{
   			$("#box-footer").html("<h1>会议活动不存在</h1>")
   		}
   	
	})
	  
	
	  
},
 methods: {
	 doSubmit: function () {
		 var _this=this;
		 if($("#signup_submit_form").valid()){
	    		var param=zfesUtil.formToJson($("#signup_submit_form"));
	    		$.extend( param,{"metId":_this.metId} )
	    		
	    		var url="/met/service/pub/signupDefine/submitSignup";
	    		zfesAjax.ajaxTodo(url,param, function(data){
	    			alertSwal.successText(data.message);
	    		})
	    	}
	    },
    	    cancel: function(){
    	    	 layer.close(layer.index);
    	    	 
    	    }
}
})

 </script>
</body>
</html>